-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable -Wparentheses warnings for g++ < 4.8 #528
Conversation
Since the changes of catchorg#247, a "warning: suggest parentheses around comparison in operand of '=='" is generated for every use of CHECK(x == y) under -Wall. Unfortunately the only way to get rid of the flood of such warnings seem to be to disable it completely. At least this only has to be done for g++ <= 4.7 as 4.8 and later don't give these warnings for the use of CHECK() any more.
Actually it looks like in more complicated cases even g++ 4.9 still warns about this. So the choice seems to be between
As much as I dislike this particular warning, I don't think (1) is acceptable, a testing library shouldn't dictate the choice of compilation options, I could live with it if this were only needed for the old compilers, but not if it's always the case. It looks like (2) should be doable, but that's a lot of work just to suppress a warning. So I really wonder if the benefits of the change in #247 were worth it and if (3) isn't the best thing to do. The fact is that using the latest CATCH I get thousands of warnings in my tests and something needs to be done about it. |
Hello, firstly, I want to warn you that this PR is a duplicate of a previous one, #521. Having said that, this problem bothers me too and I've already tried some of your propositions. I totally agree with you that (1) is not a good idea. The solution (2) is not so complicated: in fact, the warning comes from the line https://github.com/philsquared/Catch/blob/master/include/internal/catch_capture.hpp#L36 in
On my side, I couldn't suppress all warnings with this modification and it seems to be related to multiple bugs with In addition, this would imply to add such pragma for each compiler that warns about the parentheses (and I don't understand why they don't do it). About the solution (3), I think it is a good thing to allow expressions like PS: how did you gets the warning with |
@rolanddenis thanks, I didn't notice #521 somehow. I did plan to try using The case of 4.9 is weird, I can't reproduce the warning in a simple example with 4.9.3 (from Debian), but I see it in the buildbot logs on a machine using 4.9.2. FWIW the warning can be reliably reproduced in simple example with all of 4.4, 4.5, 4.6 and 4.7, it's enough to do this:
|
I took the test and what works, however, is to replace I use the version |
I'm getting this too with v1.2.1, my solution with the single header was just to change line 1574:
This allows GCC 4.9.2 to compile our tests cleanly again. (We were using v1.0.53 before w/o issue). |
Here's an example that causes 4.9.2 to emit the parens warning: error: suggest parentheses around comparison in operand of ‘==’ [-Werror=parentheses] comps is a vector of strings |
@bdb the |
@martinmoene True, but so does adding explicit parens in your test CHECK() usage. I was not suggesting my patch as official solution merely noting an easy way to solve hundreds of warnings (errors with -Werror) in one go. As I said this was an issue for us upgrading from 1.0.53, it broke a lot of tests. We've run in to parens issues before with v53, but they were minor and to solve them we did add explicit parens to the offending CHECK() statements. |
@bdb ah, I wasn't aware of its temporarilyness. |
Need a better fix for this (see discussion at catchorg/Catch2#528).
Apologies for the premature closure - I deleted the branch and it auto-closed all associated PRs - it wasn't intentional. |
Thanks Phil. Still same issue (and same workaround) in 1.3.0 |
Since the changes of #247, a "warning: suggest parentheses around comparison
in operand of '=='" is generated for every use of CHECK(x == y) under -Wall.
Unfortunately the only way to get rid of the flood of such warnings seem to be
to disable it completely. At least this only has to be done for g++ <= 4.7 as
4.8 and later don't give these warnings for the use of CHECK() any more.